﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="B2B.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<h2>AdminUpdateProduct</h2>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HEAD" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="main_content" runat="server">
    <script type="text/javascript">
        function Update(maTV) {
            var tinhtrang = document.getElementById("TinhTrang");
            var ma = document.getElementById("idSanPham");
            var json = {
                id: ma.value,
                TinhTrang: tinhtrang.value
            };
            $.ajax({
                url: '/Admin/AdminUpdateProduct',
                type: 'POST',
                contentType: 'application/json',
                dataType: 'json',
                data: JSON.stringify(json),
                success: function (response) {
                    alert(response);
                }
            });
            alert("Update success");
        }
    </script>
    <% var sp = (SanPham)ViewData["SanPham"]; %>
    <table style="width:100% ">
        <tr><th style="text-align: left; width: 189px; height: 30px">Name:</th> <td><%=sp.TenSP %></td>              <td rowspan="182><img src="../Images/Product/<%=sp.HinhAnh %>"/></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Email:</th> <td><%=sp.Gia %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Country:</th> <td><%=sp.SoLuongDatToiThieu %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Province/State:</th> <td><%=sp.KhaNangCungUng %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Name Company:</th> <td><%=sp.LoaiThanhToan %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Phone:</th> <td style="height: 30px"><%=sp.TenDanhMuc %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Company Address:</th> <td><%=sp.TenQuocGia %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Establish Year:</th> <td><%=sp.TenTV %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Website:</th> <td><%=sp.TenDVT %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Factory Address:</th> <td><%=sp.ChiTiet %></td></tr>
        <tr><th style="text-align: left; width: 189px; height: 30px">Status:</th> 
            <td>
                <select id="TinhTrang">
                    <% switch(sp.TinhTrang)
                        { 
                           case 0:%>
                            <option value ="0" selected>Waiting Accept</option>
                            <option value ="1">Reject</option>
                            <option value ="2">Accept</option>
                        <% break;
                           case 1:%>
                            <option value ="0">Waiting Accept</option>
                            <option value ="1" selected>Reject</option>
                            <option value ="2">Accept</option>
                        <% break;
                           case 2:%>
                            <option value ="0">Waiting Accept</option>
                            <option value ="1">Reject</option>
                            <option value ="2" selected>Accept</option>
                        <% break;
                    } %>
                        
                </select>
            </td>
        </tr>
        <tr>
            <td style="text-align: left; width: 189px; height: 30px"></td>
            <td>
                <input type="button" value="Update" onclick="Update()"/>
                <input type="hidden" id="idSanPham" value="<%=sp.MaSP %>"/>
            </td>

        </tr>
    </table>
</asp:Content>
